$(function() {

	var id = getQueryString("id");

	$("#aYuyue").attr("href",$("#aYuyue").attr("href")+"?id="+id);
	$("#aPingjia").attr("href",$("#aPingjia").attr("href")+"&id="+id);
	showBookDetail(id);
	showPingfen(id);
	
	function showBookDetail(id) {
		$.get({
					url : baseUrl + 'api/book/book/find',
					data : {
						id : id
					},
					success : function(data) {
						var data = data.data;
						$("#bookImage1").attr("src", data.bookImage1);
						$("#bookName").html(data.bookName);
						// 关键词
						var keyWords = data.keyWord.split(",");
						var keyWordsHtml = "";
						for (var index = 0; index < keyWords.length; index++) {
							keyWordsHtml += ' <a href="javascript:;">'
									+ keyWords[index] + '</a>';
						}
						$("#keyWord").html(keyWordsHtml);
						// 评分
						var evaluationStar = data.evaluationStar;
						var evaluationStarHtml = "";
						for (var index = 0; index < evaluationStar; index++) {
							evaluationStarHtml += '<img src="img/index/xing5@2x.png">';
						}
						$("#evaluationStarImgs").html(evaluationStarHtml);
						$("#evaluationStar").html(evaluationStar);
						// 出版社
						$("#press").html(data.press);
						$("#author").html(data.author);
						$("#describe").html(data.describe);

						$("#book_show").empty();
						var htmlOutput = $.templates("#book_show_tmpl")
								.render(data);
						$(id).html(htmlOutput);
					}
				});
	}

	function showPingfen(id) {
		$.get({
					url : baseUrl + 'api/book/bookEvaluation/findPage',
					data : {
						id : id,
						pageNum : 1,
						pageSize : 10
					},
					success : function(data) {
						var data = data.data.list;
						$("#Details_list").empty();
						var htmlOutput = $.templates("#book_evaluation_tmpl")
								.render(data);
						$("#Details_list").html(htmlOutput);
					}
				});
	}
})